﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FluentValidation;
using FluentValidation.Attributes;
using Home.Domain.Entities.Secondary.Validation;
using Home.Utilities.Validation.ExtensionMethods;
namespace Home.WebUI.Areas.Example.Models.Validation
{
    [Validator(typeof(UserInfo_RegValidator))]
    public class UserInfo_Reg:Home.Domain.Entities.Example.UserInfo
    {
        /// <summary>
        /// 确认密码
        /// </summary>
        public string VPassWord { get; set; }
        [Remote("UserExists", "UserInfo", ErrorMessage = "用户账号已存在")] 
        public override string UserName
        {
            get
            {
                return base.UserName;
            }
            set
            {
                base.UserName = value;
            }
        }
    }
    public class UserInfo_RegValidator : TPCUserInfoValidator<UserInfo_Reg>
    {
        public UserInfo_RegValidator()
        {
            RuleFor(u => u.VPassWord).Equal(u => u.PassWord).WithMessage("和密码不同"); 
        }
    }
}